package com.lanou.tipsy.tools.theme;

import android.app.Activity;
import android.content.Intent;

import com.lanou.tipsy.R;

/**
 * Created by dllo on 15/10/30.
 *   定义全局变量  用以保存主题信息
 */
public class ThemeMemory {
    public static ThemeMemory instance;
    private int mTheme;

    private ThemeMemory() {
    }

    public static ThemeMemory getInstance() {
        if (instance == null) {
            instance = new ThemeMemory();
        }
        return instance;
    }

    /**
     * 从设置界面获取主题设置信息
     *
     * @param activity
     * @param theme
     */

//    public static void changeToTheme(Activity activity,int theme){
    public void changeToTheme(Activity activity, int theme) {
        mTheme = theme;
        activity.finish();
        activity.startActivity(new Intent(activity, activity.getClass()));
    }

    /**
     * 获取并重新设置主题信息
     *
     * @param activity
     */
//    public static void onActivityCreateSetTheme(Activity activity){
    public void onActivityCreateSetTheme(Activity activity) {
        switch (mTheme) {
            default:
            case 1:
                activity.setTheme(R.style.ThemeBlue);
                break;
            case 2:
                activity.setTheme(R.style.ThemeRed);
                break;
            case 3:
                activity.setTheme(R.style.ThemeOrange);
                break;
            case 4:
                activity.setTheme(R.style.ThemeYellow);
                break;
            case 5:
                activity.setTheme(R.style.ThemeGreen);
                break;
            case 6:
                activity.setTheme(R.style.ThemeNight);
                break;
            case 7:
                activity.setTheme(R.style.ThemePurple);
                break;
            case 8:
                activity.setTheme(R.style.ThemeFeng);
                break;
        }
    }
}
